class Solution {
    public int minSubArrayLen(int target, int[] nums) {
        int left=0;
        int right=0;
        int sum=0;
        int n=nums.length+1;
        while(left<nums.length&&right<nums.length){
            sum+=nums[right];
            if(sum<target){

                right++;
            }else{
           sum=sum-nums[left]-nums[right];
           
                n=Math.min(n,right-left+1);
                 left++;
            }
           
        }
        if(n==nums.length+1){
            return 0;
        }
        return n;

    }
}